﻿Imports System.Data.Common

Public Class DComprobante
    Public COD_CENTRO, COD_USUARIO, COD_CUENTA, _
        ID_TERCERO, NUM_SOPORTE, CONCEPTO, FECHA_REGISTRO As String
    Public ID_DCPB, ID_CPB, DB, CR, BASE As Decimal

    Public Shared Function existCuenta(ByRef COD_CUENTA As String) As Boolean
        Dim conexion As New ConexionBD.ConexionBD()
        Dim dtConsulta As New DataTable
        If conexion.Conectar() Then
            Dim sentencia As String
            sentencia = "select top 1 * from DCOMPROBANTE WHERE COD_CUENTA=@COD_CUENTA"
            conexion.ParametroEntrada = New List(Of DbParameter)
            conexion.ParametroEntrada.Add(ConexionBD.ConexionBD.ParamInString(conexion, COD_CUENTA, "COD_CUENTA"))
            dtConsulta = conexion.Consulta(sentencia)
            conexion.Desconectar()
        End If

        If dtConsulta.Rows.Count <= 0 Then
            Return False
        Else
            Return True
        End If
    End Function

    Public Shared Function ConsxIdCPB(Dcomp As DComprobante) As DataTable
        Dim conexion As New ConexionBD.ConexionBD()
        Dim dtConsulta As New DataTable
        If conexion.Conectar() Then
            Dim sentencia As String
            sentencia = "SELECT COD_CUENTA,NUM_SOPORTE,CONCEPTO,DB,CR,BASE,COD_CENTRO,ID_TERCERO FROM DCOMPROBANTE WHERE ID_CPB=@ID_CPB"
            conexion.ParametroEntrada = New List(Of DbParameter)
            conexion.ParametroEntrada.Add(ConexionBD.ConexionBD.ParamInDecimal(conexion, _
                                                                              Dcomp.ID_CPB, "ID_CPB"))
            dtConsulta = conexion.Consulta(sentencia)
            conexion.Desconectar()
        End If
        Return dtConsulta
    End Function

End Class
